09. Cumulative Compounded Returns Demo
PRDTM2-786 AI Trading C3 L1 Demo
Calculating Returns Using Python
This exercise focuses on calculating and visualizing cumulative compounded returns versus sum of arithmetic returns using Python.
Initial Setup
- Assume an investment of $10,000 in a portfolio.
- Use a list of annual returns: 10%, -5%, +20%, +8%, -12%.
Steps in Python
- Import Libraries: Use
numpyfor calculations andmatplotlibfor plotting. - Prepare Data: Convert the list of annual returns into a numpy array.
Calculations:
Cumulative Compounded Returns
Sum of Arithmetic Returns
Visualization with Matplotlib:
- Plot both cumulative compounded returns and sum of arithmetic returns.
- Add labels and legends for clarity.
- Observe the different outcomes of each method.
This method utilizes numpy for efficient operations and matplotlib for clear data visualization. Comparing these methods highlights distinct insights into the nature of financial returns.